package com.lgmshare.component.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

public class ToolbarHeaderContainer extends LinearLayout {

    private HeightChangeCallback mHeightChangeCallback;
    private int mHeight;

    public ToolbarHeaderContainer(Context context) {
        super(context);
    }

    public ToolbarHeaderContainer(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if (mHeight != h) {
            if (mHeightChangeCallback != null) {
                mHeight = h;
                mHeightChangeCallback.change(h);
            }
        }
    }

    public void setHeightChangeCallback(HeightChangeCallback heightChangeCallback) {
        mHeightChangeCallback = heightChangeCallback;
    }

    public interface HeightChangeCallback {
        void change(int height);
    }
}
